package com.wangzeqi.neihanduanzi.enter;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;

import com.wangzeqi.neihanduanzi.R;
import com.wangzeqi.neihanduanzi.base.AnimationBaseActity;
import com.wangzeqi.neihanduanzi.base.BaseActivity;
import com.wangzeqi.neihanduanzi.enter.fragment.FragmentOne;
import com.wangzeqi.neihanduanzi.enter.fragment.FragmentThree;
import com.wangzeqi.neihanduanzi.enter.fragment.FragmentTwo;

/**
 * Created by dllo on 16/1/15.
 */
public class EnterPersonActivity extends BaseActivity implements View.OnClickListener {

    private TabHost tabHost;
    private android.support.v4.app.FragmentManager fm;
    private ImageView imageView, imageViewPicture;
    private TextView textView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.enter_person_activity);
        tabHost = (TabHost) findViewById(android.R.id.tabhost);
        imageView = (ImageView) findViewById(R.id.enter_person_back_bb);
        textView = (TextView) findViewById(R.id.enter_dl);
        imageViewPicture = (ImageView) findViewById(R.id.enter_person_picture);
        findViewById(R.id.enter_bttom_left).setOnClickListener(this);
        findViewById(R.id.enter_bttom_right).setOnClickListener(this);
        imageViewPicture.setOnClickListener(this);
        textView.setOnClickListener(this);
        imageView.setOnClickListener(this);

        tabHost.setup();

        TabHost.TabSpec tab1 = tabHost.newTabSpec("tab1");
        TabHost.TabSpec tab2 = tabHost.newTabSpec("tab2");
        TabHost.TabSpec tab3 = tabHost.newTabSpec("tab3");

        View view = getLayoutInflater().inflate(R.layout.tab1, null);
        View view1 = getLayoutInflater().inflate(R.layout.tab3, null);
        View view2 = getLayoutInflater().inflate(R.layout.tab4, null);
        tab1.setContent(R.id.tab1);
        tab2.setContent(R.id.tab2);
        tab3.setContent(R.id.tab3);
        tab1.setIndicator(view);
        tab2.setIndicator(view1);
        tab3.setIndicator(view2);
        tabHost.addTab(tab1);
        tabHost.addTab(tab2);
        tabHost.addTab(tab3);

        fm = getSupportFragmentManager();
        android.support.v4.app.FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.tab1, new FragmentThree());
        transaction.replace(R.id.tab2, new FragmentTwo());
        transaction.replace(R.id.tab3, new FragmentOne());
        transaction.commit();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case R.id.enter_person_back_bb:
                this.finish();
            case R.id.enter_dl:
                Intent intent = new Intent(this, EnterActivity.class);
                startActivity(intent);
                break;
            case R.id.enter_person_picture:
                Toast.makeText(this, "请先登录", Toast.LENGTH_SHORT).show();
                break;
            case R.id.enter_bttom_left:
                Toast.makeText(this, "请先登录", Toast.LENGTH_SHORT).show();
                break;
            case R.id.enter_bttom_right:
                Intent intent1 = new Intent(this, SuggestionActivity.class);
                startActivity(intent1);
                break;
        }


    }


}
